<?php
namespace app\test\controller;
use think\Db;
use think\Controller;
class Shopcart extends Controller
{
    public function index()
    {
    	$list=db('dachang_product')->alias('a')->join('dachang_shopcart b','a.product_id=b.product_id')->select();
        dump($list);
    	
        foreach ($list as $value) 
        {
            $product_num[]=$value['product_num'];
            $product_price[]=$value['product_price'];
           
        }
       
        for($i=0;$i<count($product_price);$i++)
        {
        $total[$i]=$product_num[$i]*$product_price[$i];
        }
       
        $this->assign('total',$total);
    	$this->assign('list',$list);

      return view('./test1/shopcart');
    }
    public function ajax()
    {
    	$count=$_POST['count'];
    	

    	$product_price=db('dachang_product')->where('product_id={$product_id}')->field('product_price')->select();

        $total=$count*$product_price;
    	echo $total;
    }
}